<?php 
/*
//INCLUINDO ARQUIVOS EXTERNOS
*/
require_once "includes/head.php"; 
require_once "includes/header.php";
require_once "includes/sidebar.php";
require_once "classes/Buffet.php"; //ARQUIVO DA CLASSE
require_once "tiny.php";

$buffet = new Buffet();//INSTANCIANDO A CLASSE

if(isset($_POST['editar']))
{		
	if(isset($_POST['editar']))
		$buffet->Carregar($_POST['confirma-atualizacao']);
	$buffet->SetDescricao($_POST['descricao']);
	$buffet->SetServico($_POST['servico']);
	
	$buffet->Salvar();
}


if($_GET)
{
	$acao = "editar";
	/*
	//************************************************************EXCLUIR*****************************************************
	*/
	if($_GET['funcao'] == 'excluir')
	{		
		$_id = $_GET['id'];
		$buffet->Excluir($_id);			
	}
	/*
	//************************************************************CADASTRAR OU EDITAR*****************************************************
	*/
	elseif($_GET['funcao'] == 'editar')
	{
		$acao = "editar";		
		$_id = $_GET['id'];
		$buffet->Carregar($_id);		
	}
?>

	<div class="panel-wrapper">	
		<div class="panel-wrapper fixed"><?php echo $_SESSION["mensagens"]["alerta"];?>	        
			<div class="panel">
				
				<div class="title">
					<h4><?php echo $acao;?> buffet</h4>	
				</div>
	            
	            <div id="Msg-error"><?php echo $buffet->GetErrorMsg(); ?></div><!-- MOSTRAR MsgAlerta DE VALIDACAO -->
				
				<form action="" method="post">					
					
					<div class="group fixed">
						<label for="descricao">Descrição:</label>
						<textarea name="descricao" id="descricao" cols="50" rows="15"><?php echo $buffet->GetDescricao(); ?></textarea>
					</div>
					
					<div class="group fixed">
						<label for="servicos">Serviços:</label>
						<textarea name="servico" id="servico" cols="50" rows="15"><?php echo $buffet->GetServico(); ?></textarea>
					</div>
										
                    <input type="submit" id="comparar-senha" name="<?php echo $acao;?>" value="<?php echo $acao;?>" class="button-red" />
                    <input type="hidden" value="<?php echo $_id; ?>" name="confirma-atualizacao" /><!-- PASSA O ID PELO HIDDEN NA CONFIRMAÇÃO DO CLICK -->                                                          
				</form>		
			</div><!-- panel -->
			<div class="shadow"></div>			
		</div><!-- panel-wrapper fixed -->	
	</div><!-- panel-wrapper -->

<?php		
}
	require_once "includes/footer.php"; 
?>